home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 10, No. 06 (1989-06)(MindCraft Publishing)(Side A).zip
/
Nibble Volume 10, No. 06 (1989-06)(MindCraft Publishing)(Side A).po
/
SMARTBOOT.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
11KB
|
340 lines
********************************
* SmartBoot Source Code *
* by Steve Stephenson *
* Copyright (C) 1989 *
* MicroSPARC, Inc. *
* Concord, MA 01742 *
* *
* Merlin-16 Assembler *
********************************
TR ON ;TRuncate object to 4 bytes
TR ADR ;TRuncate ADdRess to lo word
XC ;enable eXteneded opCodes
Cmd = $42 ;command (0=status, 1=rd, 2=wrt, 3=fmt)
UnitNum = $43 ;DSSS000 slot (S)/ drive (D)
DataBufr = $44,45 ;pointer to data buffer
BlkNum = $46,47 ;block number
SlotROM = $48,49 ;pointer to the interface card entry
Dir = $4A,4B ;pointer for finding file entries
LwrHalf = $4A,4B ;pointer to 1st page of the block
UprHalf = $4C,4D ;pointer to 2nd page of the block
P16:SYS:P8 = $4C ;flag for which file seeking
BlksToDo = $4D ;counter of blocks in directory
BlksDone = $4E ;counter of blocks searched
BlkIndex = $4E ;index to which block being read
RawBuffer = $50,51 ;pointer to raw data buffer
KeyBlkBuf = $1E00,1FFF ;key block buffer
PowerUp = $03F4 ;warm or cold reset check
Home = $FC58 ;monitor clear/home routine
sapling = $02*$10 ;storage type for sapling file
dirtype = $0D*$10 ;storage type for directory
*===============================
ORG $0800
dfb 01 ;signature {required}
Start
stx UnitNum ;save slot * 16
txa ;make $Csxx
and #$70
lsr
lsr
lsr
lsr
ora #$C0
sta SlotROM+1 ;set (SlotROM) = $CsFF
ldy #$FF
sty SlotROM
iny ;y=0
lda (SlotROM),y ;get re-entry offset from CsFF
beq ToError ;if 0 it's a Disk II (unsupported)
sta SlotROM ;else, finish addr setup $Csxx
sty BlkNum+1 ;hi byte of block number = 0
sty P16:SYS:P8 ;preset flag for SYSTEM/P8
iny ;setup for root dir read..
sty Cmd ; cmd=1=read
iny
sty BlkNum ; blk=2
jsr Home ;monitor clr screen
ldy Msg0 ;print title message
dey
:printlp lda Msg0+1,y ;poke the string
sta $0528,y ; to the ctr of the scrn
dey
bpl :printlp
jsr Test ;pass=0; fail=non0
beq OpenDir ;pass, stay set for P16
dec P16:SYS:P8 ;fail, dec for P8
*-------------------------------
* P16:SYS:P8 flag :
* ff = seeking PRODOS
* 00 = seeking SYSTEM/
* 01 = seeking P8
*-------------------------------
* setup two zpage pointer pairs to read the blocks into
OpenDir
lda #>$2000 ;read into memory from $2000 up
sta RawBuffer+1
sta Dir+1
stz RawBuffer
stz Dir
stz BlksDone ;clr the counters
stz BlksToDo
*-------------------------------
* read the entire directory into memory
* first time read the volume dir (to search for PRODOS)
* second time read the SYSTEM/ dir (to search for P8)
ReadDir
inc BlksToDo ;keep count of how many there are
jsr ReadBlock ;read dir block into bufr
bcc :noerr
jmp Error ;standard error handling
:noerr
ldy #2 ;point to next block link
lda (RawBuffer),y
sta BlkNum ; get the next blk number
iny
lda (RawBuffer),y
sta BlkNum+1
ora BlkNum ;see if we're done
beq NewBlk ; link=0000=no more blocks.
inc RawBuffer+1 ;else, bump destination
inc RawBuffer+1 ; up 2 pages and
bra ReadDir ; keep reading
*-------------------------------
* bump pointer to next file name; check for end of block;
* and end of directory.
NxtEntry
lda Dir ;adjust the current pointer
clc
adc #$27 ; by the length of an entry
sta Dir
bcc :1st_half ;see if we've crossed into
inc Dir+1 ; the second half of the blk
:1st_half
cmp #$FF ;at end of the blk?
bne SameBlk ; no, still in this blk
inc Dir+1 ;yes, reset to next blk
inc BlksDone ; bump counter
lda BlksDone ; and check for
cmp BlksToDo ; end of directory
ToError beq Error ;end of buffer; not found.
;(also relay from floppy)
*-------------------------------
* Enter here after reading all of the linked dir blocks
* into memory to begin the search in the first blk;
* or fall here from above to search the next block.
NewBlk
lda #4 ;start pointer just past links
sta Dir
SameBlk
lda P16:SYS:P8 ;looking for which?
bmi :Prodos ;ff
bne :P8 ;01
:System ;00
jsr FindSystem ;looking for 'SYSTEM'
bne NxtEntry ; not found yet...
beq Found
:P8
jsr FindP8 ;looking for 'P8'
bne NxtEntry
beq Found
:Prodos
jsr FindProdos ;looking for 'PRODOS'
bne NxtEntry
*-------------------------------
* When the respective 'find' routine finds it's file,
* it also checks the the storage type and file type;
* Y is left pointing at the file type...
Found
iny ;so, bump to point to key block
lda (Dir),y ;get the key blk and
sta BlkNum ; setup for next read
iny
lda (Dir),y
sta BlkNum+1
lda P16:SYS:P8 ;which are we doing?
bmi GetKeyBlk ;read in key block of PRODOS
bne GetKeyBlk ; or of P8
inc P16:SYS:P8 ;else, change flag and
bra OpenDir ; search for P8 now.
*-------------------------------
* We now know which blk is the key blk, so setup
* to read it into the 2 page area just below $2000
GetKeyBlk
lda #<KeyBlkBuf ;set pointers to $1E00
sta LwrHalf ; to read the key block
sta UprHalf
ldy #>KeyBlkBuf ;set pointers to both
sty LwrHalf+1 ; upper and lower pages
sty RawBuffer+1 ; of the blk for easier
iny ; indexing of the blks
sty UprHalf+1
stz BlkIndex ;clr the blk-to-do index
*-------------------------------
* 1st read gets the key block into the buffer 2 pages
* below $2000; subsequent reads dig out the block number
* from this key blk buffer and put the blks into memory
* starting at $2000.
ReadFile
jsr ReadBlock ;dest addr and blknum set
bcs Error
inc RawBuffer+1 ;bump destination
inc RawBuffer+1
ldy BlkIndex ;set index to find which blk
inc BlkIndex
lda (LwrHalf),y ;lookup a blk in the list
sta BlkNum
lda (UprHalf),y
sta BlkNum+1
ora (LwrHalf),y ;if 00 then we're done
bne ReadFile ;else read in another
jmp $2000 ;now run it.
*===============================
* Subroutines
*===============================
Error
jsr Home ;monitor clr screen
ldy Msg1 ;length of msg
dey
:printlp lda Msg1+1,y ;poke the string
sta $05AE,y ; to the ctr of the scrn
dey
bpl :printlp
dec PowerUp ;setup reset to cause reboot
:hang jmp :hang ;then lock up.
*===============================
* is this entry "SYSTEM/"?
FindSystem
lda System ;start with length/storage type
and #$0F ; strip to file name length
tay
:namelp lda (Dir),y ;does this character
cmp System,y ; match what we want?
bne :nomatch ;no, next name.
dey ;yes, keep matching characters
bpl :namelp
;it's a match!
:chktype ;A holds length/storage type
and #$F0 ; strip to just storage type
cmp #dirtype ;proper type?
bne Error ;good name + bad type = bad news
ldy #$10 ;reset to point to
lda (Dir),y ; the file type
cmp #$0F ; is it directory?
bne Error ;'file type mismatch'
:nomatch
rts
*===============================
* is this entry "P8"?
FindP8
lda P8
and #$0F
tay
:namelp lda (Dir),y
cmp P8,y ;match?
bne nomatch ;no, next name
dey
bpl :namelp
ChkType
and #$F0 ;storage type
cmp #sapling
bne Error
ldy #$10
lda (Dir),y ;file type
cmp #$FF ; system?
bne Error
nomatch
rts
*===============================
* is this entry "PRODOS"?
FindProdos
lda Prodos
and #$0F
tay
:namelp lda (Dir),y
cmp Prodos,y ;match?
bne nomatch ;no, next name
dey
bpl :namelp
bra ChkType ;common exit
*===============================
* use the interface card rom code to read a block
* enter with command and block number already set
* then finish passing the destination address
ReadBlock
lda RawBuffer
sta DataBufr
lda RawBuffer+1
sta DataBufr+1
jmp (SlotROM) ;returns to ReadBlock caller
*===============================
System dfb dirtype+lenSystem ;storage type & length
]name asc 'SYSTEM'
lenSystem = *-]name ; calculate name length
*-------------------------------
P8 dfb sapling+lenP8
]name asc 'P8'
lenP8 = *-]name
*-------------------------------
Prodos dfb sapling+lenProdos
]name asc 'PRODOS'
lenProdos = *-]name
*-------------------------------
*===============================
* The Test: it could be just about anything...
* In this case, make sure it's a GS then
* decide based on the state of the caps lock key
Test
sec ;standard GS test
jsr $FE1F ; is it a GS?
bcc GS ;yes ->
jsr Home ;monitor clr screen
ldy Msg2 ;length of msg
dey
:printlp lda Msg2+1,y ;poke the string
sta $05AE,y ; to the ctr of the scrn
dey
bpl :printlp
dec PowerUp ;setup reset to cause reboot
:hang jmp :hang ;then lock up.
* all of that for this ?
GS
lda $C025 ;keyboard modifier
and #%00000100 ; caps lock bit
eor #%00000100 ; if caps lock then Z=1
rts
Msg0 str "SmartBoot 8/16 (C)1989 MicroSPARC, Inc."
Msg1 str "*** Unable To Load ProDOS ***"
Msg2 str "*** REQUIRES AN APPLE IIGS ***"
end ds \ ;pad to $09FF